<!--#index.html-->
<!--body-->
<script>
    $(function() {
        $("#form").ajaxForm({
            success : function(data) {
                if(data.msg) {
                    $(".alert span").text(data.msg);
                    $(".alert").removeClass("alert-success").addClass("alert-error");
                    $(".alert").fadeOut("fast").fadeIn("fast")
                } else {
                    $(".alert span").html("修改成功");
                    $(".alert").removeClass("alert-error").addClass("alert-success");
                    $(".alert").fadeOut(0).fadeIn("fast");
                }
            },
            beforeSubmit : function() {
                if($("#pwd").val() != $("#pwd2").val()) {
                    $(".alert span").text("密码不一致，请重新输入");
                    $(".alert").fadeOut("fast").fadeIn("fast");
                    $("#pwd2").focus();
                    return false;
                }
                return true;
            }
        })
        $(".alert button").click(function() {
            $(".alert").hide("fast")
        })
        $("#changepwd").click(function(e) {
            e.preventDefault();
            $(this).remove();
            $(".pwddiv").show();
        })
        $(".pwddiv").hide();
    })
</script>
<form action="user.update" method="post" id="form" class="form-horizontal">
    <legend>更改用户资料</legend>
    <div class="alert alert-error">
        <button type="button" class="close">×</button>
        <span></span>
    </div>
    <div class="control-group">
        <label class="control-label" for="id">登录名</label>
        <div class="controls">
            <input type="text" id="id" placeholder="" value="${user.id}" readonly="readonly"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="name">昵称</label>
        <div class="controls">
            <input type="text" id="name" placeholder="" name="user.name" value="${user.name}"/>
            <span class="help-inline">长度1-20</span>
        </div>
    </div>
    <div class="control-group pwddiv">
        <label class="control-label" for="oldpwd">原始密码</label>
        <div class="controls">
            <input type="password" id="oldpwd" placeholder="" name="oldpwd"/>
        </div>
    </div>
    <div class="control-group pwddiv">
        <label class="control-label" for="pwd">新密码</label>
        <div class="controls">
            <input type="password" id="pwd" placeholder="" name="user.pwd"/>
            <span class="help-inline">长度6-20</span>
        </div>
    </div>
    <div class="control-group pwddiv">
        <label class="control-label" for="pwd2">请再输入一次新密码</label>
        <div class="controls">
            <input type="password" id="pwd2" placeholder=""/>
            <span class="help-inline">与新密码一致</span>
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <input type="submit" value="修改" class="btn btn-primary"/>
            <input type="reset" value="重置" class="btn btn-primary"/>
            <button onclick="$('.pwddiv').show();$(this).remove()" class="btn btn-mini">修改密码</button>
        </div>
    </div>
</form>
<!--body end-->
<!--#index.html end-->